/**
 * @description Description
 *
 * @author Candy <candy.yan@motionglobal.com>
 * @date  Creation Date 2018/7/25
 */

import {
  GET_USERINFO,
  RECORD_USERINFO,
  LOGOUT,
  RECORD_CURMENU,
  RECORD_ROUTESUBPAGE,
  RECORD_WAITTOCONFIRM,
  RECORD_WAITTOSHIP,
  RECORD_CREATESHIP,
  RECORD_IMPORTSHIPMENTFORMDATA
} from './mutation-types';

import {setStore, getStore, removeStore} from '@/utils/index';


export default {
  [GET_USERINFO](state, userInfo) {
    state.userInfo = userInfo;
    setStore('user_id',userInfo.user_id)
  },
  //record user info
  [RECORD_USERINFO](state, userInfo) {
    state.userInfo = userInfo;
    setStore('user_id',userInfo.user_id)
  },
  [LOGOUT](state) {
    state.userInfo = {};
    removeStore('user_id');
  },
  //record current menu
  [RECORD_CURMENU](state, curMenuSelected) {
    let stateOpenNames = state.cueMenuProps.openNames;
    state.cueMenuProps.activeName = curMenuSelected.activeName;
    stateOpenNames.length = 0; // clear array data
    stateOpenNames.push(curMenuSelected.openNames);
  },
  //record route subpage
  [RECORD_ROUTESUBPAGE](state, routeSubPage) {
    state.routeSubPage = routeSubPage;
  },
  // record wait to confirm data
  [RECORD_WAITTOCONFIRM](state, data) {
    state.curWaitToConfirmData = data;
  },
  // record wait to ship data
  [RECORD_WAITTOSHIP](state, data) {
    state.curWaitToShipData = data;
  },
  // record create ship item list
  [RECORD_CREATESHIP](state, data) {
    state.createShipmentList = data;
  },
  // record create ship item list
  [RECORD_IMPORTSHIPMENTFORMDATA](state, data) {
    state.importShipmentFormData = data;
  }
}
